<?php
/**
 * Created by PhpStorm.
 * User: 王峥宇
 * Date: 2019-04-29
 * Time: 18:36
 */

namespace app\shop\model;


use think\Session;

class Shop extends BaseModel
{
    public function indentShop(){
        return $this->belongsTo('Indent','shopid','shopid');
    }


    public static function getShopUser(){
        $user = Session::get('id');
        $shopuser = self::where('id',$user)->find();
        return $shopuser;
    }

    public static function getShopIndent(){
        $user = Session::get('id');
        $shopuser = self::where('id',$user)->find();
        $indent = new Indent();
        $shopindent = $indent->where('shopid','eq',$shopuser['shopid']  )->paginate();
        return $shopindent;
    }
  
  	public static function getPassword(){
        $user = Session::get('id');
        $shopuser = self::where('id',$user)->find();
        if (request()->isAjax()) {
            $data['password'] = md5(input('pwd'));
            $up = self::where('id',$shopuser['id'])->update($data);
            if ($up){
                return 1;
            }else{
                return 0;
            }
        }
        return $shopuser;
    }

}